{% set pypi_name = 'oslo.privsep' %}
{% set upstream_version = upstream_version('2.4.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack library for privilege separation
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('cffi') }}
BuildRequires:  {{ py3('eventlet') }}
BuildRequires:  {{ py3('greenlet') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('msgpack') }}
BuildRequires:  {{ py3('oslo.config') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslo.log') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('stestr') }}
BuildArch:      noarch

%description
OpenStack library for privilege separation

%package -n {{ py2name(py_versions='py3') }}
Summary:        OpenStack library for privilege separation
Requires:       {{ py3('cffi') }}
Requires:       {{ py3('eventlet') }}
Requires:       {{ py3('greenlet') }}
Requires:       {{ py3('msgpack') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.log') }}
Requires:       {{ py3('oslo.utils') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 2.0.0
%endif

%description -n {{ py2name(py_versions='py3') }}
OpenStack library for privilege separation

%package -n {{ py2name() }}-doc
Summary:        oslo.privsep documentation
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('sphinxcontrib-apidoc') }}

%description -n {{ py2name() }}-doc
Documentation for oslo.privsep

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%py3_build
# generate html docs
PBR_VERSION=%{version} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%py3_install

%check
export PYTHONPATH=.
python3  -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%doc README.rst
%license LICENSE
%{_bindir}/privsep-helper
%{python3_sitelib}/oslo_privsep
%{python3_sitelib}/{{ pypi_name }}-*-py?.?.egg-info

%files -n {{ py2name() }}-doc
%doc doc/build/html

%changelog
